package com.wjx.demo.tclass

class A<T> {
    constructor(t: T) {
        this.t = t
    }

    var t: T? = null
    fun out() {
        println(t)
    }
}

fun <T> f(t: T) {
    println(t)
}

open class C {
    open fun p() {
        println("C")
    }
}

class CC : C() {
    override fun p() {
        println("CC")
    }
}

//类似java 的 <？ extends C>
fun <T : C> p(t: T) {
    t.p()
}

fun main(args: Array<String>) {
    var a = A<Int>(1)
    var c = A(1)
    var b = A<String>("aaa")
    a.out()
    c.out()
    b.out()

    f("a")
    f(1)

    p(C())
    p(CC())
}